#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int oldfd1 = open("a.txt", O_RDWR | O_CREAT, 0644);
    int oldfd2 = open("b.txt", O_RDWR | O_CREAT, 0644);
    int newfd = dup(oldfd1);
    dup2(oldfd1, 0);
    char buf[30];
    read(0, buf, 28);
    printf("Read from a.txt: %s\n", buf);
    close(oldfd1);
    close(oldfd2);
    close(newfd);
    return 0;
}